package com.zxwl.obs.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import net.sf.json.JSONObject;

import com.zxwl.base.action.BaseAction;
import com.zxwl.base.dao.QueryParameter;
import com.zxwl.base.service.IBaseService;
import com.zxwl.common.log.ILogger;
import com.zxwl.common.log.LoggerManager;
import com.zxwl.obs.entity.HuaweiHoliday;

@Component
public class HuaweiHolidayAction extends BaseAction<HuaweiHoliday>
{

	private static final long serialVersionUID = 4744216044913605232L;
	
	private final ILogger logger = LoggerManager.getLogger(HuaweiHolidayAction.class);

	@Override
	@Resource
	public void setService(IBaseService<HuaweiHoliday> huaweiHolidayService)
	{
		this.service = huaweiHolidayService;
	}

	@Override
	public void fullQueryParameter(QueryParameter queryParameter)
	{
		
	}

	@Override
	public String save()
	{
		try
		{
			this.logger.info("开始保存节假日实体！");
			
			Integer holidayId = 1;
			List<HuaweiHoliday> holidays = this.service.queryList(null);
			if(null != holidays && 0 < holidays.size())
			{
				holidayId = holidays.size() + 1;
			}
			
			HuaweiHoliday entity = this.getEntity();
			entity.setHolidayId(holidayId);
			
			HuaweiTaskAction.dataMap.put("HuaweiHoliday", entity);
			
			this.logger.info("保存节假日实体成功，entity："+JSONObject.fromObject(entity));
		}
		catch (Exception e)
		{
			this.logger.error("【error】保存节假日实体异常！", e);
		}
		return null;
	}
	
	

}
